﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace QD.Validate
{
    public class RegexRule : IValidateRule<String>
    {
        public Boolean IngoreCase { get; set; }
        public String Expression { get; set; }
        public String Tips { get; set; }
        public Boolean IsValidate(String value)
        {
            if (value == null) return false;
            RegexOptions options = RegexOptions.None;

            if (IngoreCase) options = RegexOptions.IgnoreCase | options;

            return Regex.IsMatch(value, Expression, options);
        }
    }
}
